package com.example.liwushuo.adapter;

import java.util.List;

import android.content.Context;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.liwushuo.BaseApp;
import com.example.liwushuo.R;
import com.example.liwushuo.bean.Comment;
import com.lidroid.xutils.ViewUtils;
import com.lidroid.xutils.view.annotation.ViewInject;

public class UserAdapter extends AppAdapter<Comment> {

	public UserAdapter(Context context, List<Comment> list) {
		super(context, list);
		Log.i("userBean", "--------" + list.size());
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHolder holder;
		if (convertView == null) {

			convertView = inflater.inflate(R.layout.user_item, null);
			holder = new ViewHolder(convertView);
			convertView.setTag(holder);
		} else {
			holder = (ViewHolder) convertView.getTag();
		}

		holder.name.setText(list.get(position).getUser().getNickname());
		holder.to.setText("回复："
				+ list.get(position).getReplied_user().getNickname() + ":"
				+ list.get(position).getContent());

		BaseApp.getBitmapUtils().display(holder.img,
				list.get(position).getUser().getAvatar_url());
		return convertView;
	}

	private static class ViewHolder {
		ImageView img;
		TextView name;
		TextView to;
		TextView time;

		public ViewHolder(View view) {
			img = (ImageView) view.findViewById(R.id.user_img);
			name = (TextView) view.findViewById(R.id.user_name);
			to = (TextView) view.findViewById(R.id.user_to_tall);
			time = (TextView) view.findViewById(R.id.user_to_tiem);
		}
	}
}
